package com.simpleframe.views.components;

import java.io.Writer;

import com.simpleframe.util.StringUtil;

public class Out extends Component {
	
	protected String value;
	protected Integer length;
	protected Boolean html;
	
	@Override
	public boolean end(Writer writer, String tagBody) {
		evaluateParameters();
		mergeTemplate(writer,getTemplate());
		return false;
	}
	
	protected void evaluateParameters(){
		if(value!=null){
			if(length!=null){
				value = (String)StringUtil.truncate(value, length, "...");
			}
			addParameter("value", value);
		}

		
		if(html!=null){
			addParameter("html",html);
		}
		
	}

	public void setValue(String value) {
		this.value = value;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public void setHtml(Boolean html) {
		this.html = html;
	}
}
